class Animal {
    public String name;
    public int age;


//    public Animal(String name, int age) {
//        this.name = name;
//        this.age = age;
//    }

    public void eat() {
        System.out.println(this.name + "吃食物");
    }

    @Override
    public String toString() {
        return this.age+"岁的"+this.name+"吃食物";
    }
}
class Dog extends Animal{
    public void bark(){
        System.out.println(this.name + "汪汪");
    }
}
public class Test1 {
    public static void main(String[] args) {
//        Animal d = new Animal("大黄",10);
//        System.out.println(d);
        Dog d= new Dog();//
        System.out.println(d.name);//继承了Animal父类的name
        System.out.println(d.age);//继承了Animal父类的age
        d.eat();//继承了Animal的方法
        d.bark() ;
    }
}
